//
//  ViewController.m
//  Homework2016-06-03
//
//  Created by Roach on 16/6/3.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "ViewController.h"


@interface ViewController ()

@end

@implementation ViewController

- (void) dealloc {
    
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self creatView];
    [self creatView];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

// 第一题
#if 0
- (void) creatView {
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(50, 100, 200, 100)];
    view1.backgroundColor = [UIColor redColor];
    [self.view addSubview:view1];
    [view1 release];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(100, 150, 200, 100)];
    view2.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:view2];
    [view2 release];
    
    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(150, 200, 200, 100)];
    view3.backgroundColor = [UIColor blueColor];
    [self.view addSubview:view3];
    [view3 release];
    
    UIView *view4 = [[UIView alloc] initWithFrame:CGRectMake(200, 250, 200, 100)];
    view4.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view4];
    [view4 release];
    
}
#endif

// 第二题
#if 0
-(void) creatView1 {
    self.view.backgroundColor = [UIColor grayColor];
    self.view.alpha = 0.9;
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(40, 80, 60, 40)];
    view1.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view1];
    [view1 release];
    
    UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(130, 80, 130, 40)];
    view2.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view2];
    [view2 release];
    
    UIView *view3 = [[UIView alloc]initWithFrame:CGRectMake(40, 150, 60, 40)];
    view3.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view3];
    [view3 release];
    
    UIView *view4 = [[UIView alloc]initWithFrame:CGRectMake(130, 150, 130, 40)];
    view4.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view4];
    [view4 release];
    
    UIView *view5 = [[UIView alloc]initWithFrame:CGRectMake(50, 215, 50, 30)];
    view5.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view5];
    [view5 release];
    
    UIView *view6 = [[UIView alloc]initWithFrame:CGRectMake(180, 215, 45, 30)];
    view6.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:view6];
    [view6 release];
}
#endif

// 第三题
#if 1
- (void) creatView {
    for (int i = 0; i < 8; i ++) {
        for (int j = 0; j < 5; j ++) {
            UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(j * 75, i * 95.2, 75, 95.2)];
            view1.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 
            [self.view addSubview:view1];
            [view1 release];
        }
    }
}
#endif

@end
